package com.king.designpatterns.结构型模式.代理模式;

import java.util.Date;

/**
 * 代理类
 *
 * @author king
 * @date 2021-06-08 10:56
 */
public class GamePlayerProxy implements IGamePlayer{
    private IGamePlayer player;

    public GamePlayerProxy(IGamePlayer player) {
        this.player = player;
    }

    /**
     * 记录打怪的时间
     */
    private void log(){
        System.out.println("打怪时间：" + new Date().toString());
    }

    @Override
    public void killBoss() {
        this.log();
        player.killBoss();
    }

    @Override
    public void upgrade() {
        player.upgrade();
        this.count();
    }

    /**
     * 计算升级所用的时间
     */
    private void count(){
        System.out.println("升1级耗费50小时");
    }
}
